import java.util.Arrays;
import java.util.Random;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void readyDataOrder(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
            //array[i] = array.length-i;
        }
    }


    public static void readyDataNotOrder(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100000);
        }
    }

    public static void testInsertSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.insertSort(array);
        long end = System.currentTimeMillis();
        System.out.println("插入排序耗时参考："+(end-start));
    }

    public static void testShellSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.shellSort(array);
        long end = System.currentTimeMillis();
        System.out.println("希尔排序耗时参考："+(end-start));

    }

    public static void testSelectSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.selectSort(array);
        long end = System.currentTimeMillis();
        System.out.println("选择排序耗时参考："+(end-start));

    }

    public static void testHeapSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.heapSort(array);
        long end = System.currentTimeMillis();
        System.out.println("堆排排序耗时参考："+(end-start));
    }

    public static void testBubbleSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long end = System.currentTimeMillis();
        System.out.println("冒泡排序耗时参考："+(end-start));
    }

    public static void testQuickSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long start = System.currentTimeMillis();
        Sort.quickSort(array);
        long end = System.currentTimeMillis();
        System.out.println("快速排序耗时参考："+(end-start));
    }

    public static void main1(String[] args) {
        int[] array = new int[10_0000];
        readyDataOrder(array);
        /*testInsertSort(array);*/
        testShellSort(array);
        //testSelectSort(array);
        testHeapSort(array);
        //testBubbleSort(array);
        testQuickSort(array);
    }



    public static void main(String[] args) {
        int[] array = {3,1,2,6,8,4,5,7,1,3,2,4,7,6,5,8,9,3,2,1};
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
